package com.ganinfo.sys.service.impl;


import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ganinfo.common.data.TransmitMap;

import com.ganinfo.sys.mapper.SysUserMapper;
import com.ganinfo.sys.model.SysUser;
import com.ganinfo.sys.service.ISysUserService;


/**
 * @ClassName:   SysUserServiceImpl
 * @Description: [sys_user]业务接口实现类
 * @author:      ruikanwang
 * @date:       
 */
@Service
public class SysUserServiceImpl implements ISysUserService {
	@Autowired
	SysUserMapper dao; // mapper

	@Autowired
	SQLManager sql;

	@Override
	public PageQuery<Object> getSysUserList(TransmitMap transmitMap) {
		PageQuery<Object> pageQuery = new PageQuery<>();
		if(transmitMap.get("orderby")==null){
			//pageQuery.setOrderBy("id desc");
		}else{
			pageQuery.setOrderBy(transmitMap.getString("orderby")+" "+transmitMap.getString("orderbymethod"));
		}
		pageQuery.setPageSize(Integer.parseInt(transmitMap.get("pageSize").toString()));
		pageQuery.setPageNumber(Integer.parseInt(transmitMap.get("pageNumber").toString()));
		pageQuery.setParas(transmitMap);
		sql.pageQuery("sysUser.getSysUserListByPage", TransmitMap.class, pageQuery);
		return pageQuery;
	}

	@Override
	public boolean addSysUser(SysUser paramSysUser) {
		dao.insertTemplate(paramSysUser);
		return true;
	}

	@Override
	public boolean updateSysUser(SysUser paramSysUser) {
		if(dao.updateTemplateById(paramSysUser)!=-1){
			return true;
		}
		return false;
	}

	@Override
	public boolean deleteSysUser(SysUser paramSysUser) {
		if(dao.deleteById(paramSysUser.getId())!=-1){
			return true;
		}
		return false;
	}



}